package com.bckj.fastboot.upms.api.service;

import com.bckj.fastboot.core.lang.model.PageResult;
import com.bckj.fastboot.upms.api.constant.UpmsConstant;
import com.bckj.fastboot.upms.api.dto.SysUserQuery;
import com.bckj.fastboot.upms.api.dto.SysUserRequest;
import com.bckj.fastboot.upms.api.dto.UserAuthInfo;
import com.bckj.fastboot.upms.api.entity.SysUser;
import com.bckj.fastboot.upms.api.vo.SysUserVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

/**
 * 系统用户
 *
 * @author wfc
 * @since 2023-06-05 15:05:59
 */
@FeignClient(value = UpmsConstant.SERVICE_ID, contextId = "sysUser", path = "sysUser")
public interface SysUserRemoteService {

    /**
     * 分页
     */
    @GetMapping("page")
    PageResult<SysUserVO> page(@SpringQueryMap SysUserQuery query);

    /**
     * 增加
     */
    @PostMapping("save")
    boolean save(@RequestBody @Validated SysUserRequest request);

    /**
     * 更新
     */
    @PutMapping("update")
    boolean update(@RequestBody @Validated SysUserRequest request);

    /**
     * 获取明细
     */
    @GetMapping("/{id}")
    SysUserVO details(@PathVariable("id") Long id);

    /**
     * 启用/禁用
     */
    @PutMapping("/{id}/enabled")
    boolean enabled(@PathVariable("id") Long id);

    /**
     * 移除
     *
     * @param id id
     * @return boolean
     */
    @DeleteMapping("{id}")
    boolean remove(@PathVariable("id") Long id);

    /**
     * 根据用户名查询用户信息
     * @param username 用户名
     * @return {@link UserAuthInfo}
     */
    @GetMapping("findByUsername")
    UserAuthInfo findByUsername(@RequestParam("username") String username);

    /**
     * 保存权限
     */
    @PostMapping("savePerms")
    boolean savePerms(@RequestBody SysUserRequest request);

    /**
     * 根据ids获取信息
     * @param ids id set
     * @return resp
     */
    @PostMapping("findByIds")
    Set<SysUser> findByIds(@RequestBody Set<Long> ids);

}
